<?php


namespace Mslynn\Log\Observer;


use Magento\Catalog\Model\Product;
use Magento\Customer\Model\Session;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Event\ObserverInterface;
use Mslynn\Log\Logger\Cart\Logger;

class CartComplete implements  ObserverInterface
{
    protected $_logger;
    protected $_session;
    public function __construct(
        Session $session,
        Logger $logger
    )
    {
        $this->_session = $session;
        $this->_logger = $logger;
    }
    public function execute(\Magento\Framework\Event\Observer  $observer)
    {
        /**
         * @var Product $product
         */

        $isLoggedIn = $this->_session->isLoggedIn();
        if ($isLoggedIn) {
                $customer_id=$this->_session->getCustomerId();
        }else{
            $customer_id=0;
        }
        /**
         * @var RequestInterface $request
         */
        $request=$observer->getData('request');

        $this->_logger->info('购物车信息',['customer_id'=>$customer_id,'request'=>$request->getParams()]);
    }
}